<!-- 打赏支持模块 - 悬停弹出版 -->
<section class="reward-section">
    <div class="reward-hover-container">
        <!-- 打赏按钮 -->
        <div class="reward-trigger">
            <span class="reward-icon">💖</span>
            <span class="reward-text">打赏支持</span>
        </div>
        
        <!-- 悬停弹出的二维码卡片 -->
        <div class="reward-popup">
            <div class="reward-popup-inner">
                <h4>感谢支持</h4>
                <p>您的支持是我持续创作的动力</p>
                
                <!-- 支付方式选择 -->
                <div class="payment-selector">
                    <div class="payment-option active" data-payment="alipay">
                        <div class="payment-icon alipay-icon">💙</div>
                        <span>支付宝</span>
                    </div>
                    <div class="payment-option" data-payment="wechat">
                        <div class="payment-icon wechat-icon">💚</div>
                        <span>微信</span>
                    </div>
                </div>
                
                <!-- 二维码显示 -->
                <div class="qrcode-display">
                    <img id="reward-qrcode" src="/images/payimg/alipayimg.png" alt="扫码支付" />
                    <p class="qr-tip">扫码即可支持</p>
                </div>
            </div>
        </div>
    </div>
</section>

<style>
/* 打赏悬停容器 */
.reward-section {
    text-align: center;
    margin: 30px 0;
}

.reward-hover-container {
    position: relative;
    display: inline-block;
}

/* 打赏触发按钮 */
.reward-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: white;
    border-radius: 25px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
    transition: all 0.3s ease;
    border: none;
}

.reward-trigger:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.4);
    background: linear-gradient(135deg, #ee5a24, #ff6b6b);
}

.reward-icon {
    font-size: 18px;
    animation: heartbeat 2s infinite;
}

@keyframes heartbeat {
    0%, 50%, 100% { transform: scale(1); }
    25%, 75% { transform: scale(1.1); }
}

/* 悬停弹出卡片 */
.reward-popup {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 15px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
}

.reward-hover-container:hover .reward-popup {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-10px);
}

.reward-popup-inner {
    background: white;
    border-radius: 12px;
    padding: 20px;
    min-width: 280px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    border: 1px solid #eee;
    position: relative;
}

/* 小箭头 */
.reward-popup-inner::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 8px solid transparent;
    border-top-color: white;
}

.reward-popup-inner::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 9px solid transparent;
    border-top-color: #eee;
    z-index: -1;
}

/* 标题 */
.reward-popup h4 {
    margin: 0 0 8px 0;
    font-size: 16px;
    color: #333;
    text-align: center;
}

.reward-popup p {
    margin: 0 0 16px 0;
    font-size: 12px;
    color: #666;
    text-align: center;
}

/* 支付方式选择 */
.payment-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    justify-content: center;
}

.payment-option {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px;
    border: 2px solid #eee;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 12px;
    color: #666;
}

.payment-option:hover {
    border-color: #ccc;
}

.payment-option.active {
    border-color: #1677ff;
    background: #f0f8ff;
    color: #1677ff;
}

.payment-option.active[data-payment="wechat"] {
    border-color: #07c160;
    background: #f0fff4;
    color: #07c160;
}

.payment-icon {
    font-size: 16px;
}

/* 二维码显示 */
.qrcode-display {
    text-align: center;
}

.qrcode-display img {
    width: 120px;
    height: 120px;
    border-radius: 8px;
    margin-bottom: 8px;
    border: 1px solid #eee;
}

.qr-tip {
    margin: 0;
    font-size: 11px;
    color: #888;
}

/* 响应式设计 */
@media (max-width: 480px) {
    .reward-popup-inner {
        min-width: 240px;
        padding: 16px;
    }
    
    .qrcode-display img {
        width: 100px;
        height: 100px;
    }
    
    .payment-selector {
        flex-direction: column;
        gap: 8px;
    }
    
    .payment-option {
        flex-direction: row;
        justify-content: center;
    }
}

/* 暗黑模式支持 */
@media (prefers-color-scheme: dark) {
    .reward-popup-inner {
        background: #2a2a2a;
        border-color: #444;
        color: #e0e0e0;
    }
    
    .reward-popup-inner::after {
        border-top-color: #2a2a2a;
    }
    
    .reward-popup-inner::before {
        border-top-color: #444;
    }
    
    .reward-popup h4 {
        color: #e0e0e0;
    }
    
    .reward-popup p {
        color: #ccc;
    }
    
    .payment-option {
        background: #333;
        border-color: #444;
        color: #ccc;
    }
    
    .payment-option:hover {
        border-color: #555;
    }
    
    .qrcode-display img {
        border-color: #444;
    }
    
    .qr-tip {
        color: #999;
    }
}
</style>

<script>
// 简单的打赏悬停功能
(function() {
    'use strict';
    
    let isInitialized = false;
    
    function initRewardHover() {
        if (isInitialized) return;
        
        // 查找打赏相关元素
        const rewardContainer = document.querySelector('.reward-hover-container');
        const paymentOptions = document.querySelectorAll('.payment-option');
        const qrcode = document.getElementById('reward-qrcode');
        
        if (!rewardContainer || !qrcode) {
            console.log('打赏元素未找到');
            return;
        }
        
        // 支付方式切换
        paymentOptions.forEach(option => {
            option.addEventListener('click', function() {
                // 移除其他选项的active状态
                paymentOptions.forEach(opt => opt.classList.remove('active'));
                // 添加当前选项的active状态
                this.classList.add('active');
                
                // 切换二维码
                const payment = this.dataset.payment;
                if (payment === 'alipay') {
                    qrcode.src = '/images/payimg/alipayimg.png';
                } else if (payment === 'wechat') {
                    qrcode.src = '/images/payimg/weipayimg.png';
                }
                
                console.log('切换到', payment, '支付方式');
            });
        });
        
        isInitialized = true;
        console.log('Reward hover system initialized');
    }
    
    // 初始化
    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', initRewardHover);
    } else {
        initRewardHover();
    }
    
    // Pjax 兼容性
    document.addEventListener('pjax:complete', function() {
        isInitialized = false;
        setTimeout(initRewardHover, 100);
    });
})();
</script>
